<?php
namespace app\admin\controller;

use think\Controller;

use app\admin\controller\Base;

use think\Db;
use think\Session;

class Coach extends Base
{
    public function lst()//列表页
    {
        $coach_lst=db('coach')->select();
        $this->assign('info',$coach_lst);
        return $this->fetch();
    }

   public function checkstatusr()
   {
       $coach_id=input('coach_id');
       $coach_status=db('coach')->where('coach_id',$coach_id)->field('coach_status')->find();
       if($coach_status['coach_status']==0)
        {
            $coach_statusr=['coach_status'=>1];
            
            $res=db('coach')->where("coach_id",$coach_id)->update($coach_statusr);

            if($res)
            {
                return $this->success('修改成功！','lst');//跳转到用户列表页
            }
            else{
                return $this->error('修改失败!');
        }
        }else if($coach_status['coach_status']==1)
            {
                $coach_statusr=['coach_status'=>0];
                
                $res=db('coach')->where("coach_id",$coach_id)->update($coach_statusr);
                
                if($res)
                {
                    return $this->success('修改成功！','lst');//跳转到用户列表页
                }
                else{
                    return $this->error('修改失败!');
            }
            }
        }
   }